home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / DLLCust_Files / AXON / BKLINEAR.C < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-08  |  1.4 KB  |  46 lines

  1. // Dynamic link library implementation of NeuroSolutions BackLinearAxon component using the performBackAxon protocol
  2.  
  3. #include "NSDLL.h" 
  4.  
  5. /* Backpropagation of component */
  6.  
  7. __declspec(dllexport) void performBackAxon(
  8.     void    *instance,    // Pointer to instance data
  9.     void    *dualInstance,    // Pointer to the forward axons instance data
  10.     NSFloat    *data,         // Pointer to the layer of processing elements (PEs)
  11.     int     rows,        // Number of rows of PEs in the layer
  12.     int     cols,        // Number of columns of PEs in the layer
  13.     NSFloat    *error         // Pointer to the sensitivity vector
  14.     )
  15. {
  16.     int i,length=rows*cols;
  17.     NSFloat *gradient = getWeights(instance);
  18.     NSFloat beta = getFloatParameter(dualInstance, 2, 1);
  19.  
  20.     for (i=0; i<length; i++) {
  21.         error[i] *= beta;
  22.         gradient[i] += error[i];
  23.     }
  24. }
  25.  
  26. /******************************************/
  27. /* Management of instance data (OPTIONAL) */
  28.  
  29. __declspec(dllexport) DLLData *allocBackAxon(
  30.     DLLData    *oldInstance,    // Pointer to the last instance if reallocating
  31.     DLLData    *dualInstance,    // Pointer to forward axonÆs instance data (may be NULL)
  32.     int     rows,        // Number of rows of PEs in the layer
  33.     int     cols        // Number of columns of PEs in the layer
  34.     )
  35. {
  36.     DLLData *instance = allocDLLInstance(oldInstance);
  37.     setWeights(instance, rows*cols);
  38.     return instance;
  39. }
  40.  
  41. __declspec(dllexport) void freeBackAxon(DLLData *instance)
  42. {
  43.     freeDLLInstance(instance);
  44. }
  45.  
  46.